﻿#pragma once

#include "Types.h"

#include <string>
#include <vector>

namespace Lisp
{
  class Reader
  {
  public:
    Reader(const std::vector<std::string> &tokens);
    ~Reader();

    size_t Next();
    bool HasNext() const { return m_index + 1 <= m_tokens.size(); };
    const std::string &Peek() const;
    const size_t GetIndex() const { return m_index; };
    const size_t Size() const { return m_tokens.size(); };
    const std::string &GetToken(size_t index) const { return m_tokens[index]; };

  private:
    std::vector<std::string> m_tokens;
    size_t m_index;
  };

  ValPtr ReadStr(const std::string &input);

  ValPtr ReadFrom(Reader &reader);

  ValPtr ReadAtom(Reader &reader);

  void ReadList(Reader &reader, ValVec* list, const std::string &end);

  std::vector<std::string> Tokenize(const std::string &str);

}